// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Core;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using System;
using System.Runtime.Serialization;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.SearchableSnapshots;

[JsonConverter(typeof(StatsLevelConverter))]
public enum StatsLevel
{
	[EnumMember(Value = "shards")]
	Shards,
	[EnumMember(Value = "indices")]
	Indices,
	[EnumMember(Value = "cluster")]
	Cluster
}

internal sealed class StatsLevelConverter : JsonConverter<StatsLevel>
{
	public override StatsLevel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
	{
		var enumString = reader.GetString();
		switch (enumString)
		{
			case "shards":
				return StatsLevel.Shards;
			case "indices":
				return StatsLevel.Indices;
			case "cluster":
				return StatsLevel.Cluster;
		}

		ThrowHelper.ThrowJsonException();
		return default;
	}

	public override void Write(Utf8JsonWriter writer, StatsLevel value, JsonSerializerOptions options)
	{
		switch (value)
		{
			case StatsLevel.Shards:
				writer.WriteStringValue("shards");
				return;
			case StatsLevel.Indices:
				writer.WriteStringValue("indices");
				return;
			case StatsLevel.Cluster:
				writer.WriteStringValue("cluster");
				return;
		}

		writer.WriteNullValue();
	}
}